# Maintainer: taozuhong <taozuhong@gmail.com>

_realname=scintilla
pkgbase=mingw-w64-${_realname}-gtk3
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-gtk3"
pkgver=4.4.4
pkgrel=2
pkgdesc="A text widget adding syntax highlighting and more to GNOME (mingw-w64)"
arch=('any')
url="https://www.scintilla.org/"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-python3")
depends=("${MINGW_PACKAGE_PREFIX}-gtk3")
source=("https://www.scintilla.org/scintilla444.tgz"
        "scintilla.pc")
sha256sums=('1ee9dda1ee99d2ba8fed00991bc2d7da20ef31da7db49a72e28c441ca3595afe'
            '1abd8af52127dfdc49d2c3dd8ff4428f4665cde60fe645b2f4a718c306c329db')

prepare() {
  cd ${_realname}
  
  export windir=${WINDIR}
}

build() {  
  cd ${srcdir}/${_realname}/gtk
  make GTK3=1 PREFIX='${MINGW_PREFIX}' BUILD='${MINGW_CHOST}' HOST='${MINGW_CHOST}' TARGET='${MINGW_CHOST}'
  
  cp -f "${srcdir}/${_realname}.pc" "${srcdir}/${_realname}/bin/${_realname}.pc"
  sed -i -e "s#@prefix@#${MINGW_PREFIX}#g" "${srcdir}/${_realname}/bin/${_realname}.pc"
}

package() {  
  # pkg-config
  install -Dm644 "${srcdir}/${_realname}.pc" "${pkgdir}${MINGW_PREFIX}/lib/pkgconfig/${_realname}-gtk3.pc"
  
  # library
  install -Dm644 "${srcdir}/${_realname}/bin/liblexilla.a" "${pkgdir}${MINGW_PREFIX}/lib/liblexilla.a"
  install -Dm644 "${srcdir}/${_realname}/bin/scintilla.a" "${pkgdir}${MINGW_PREFIX}/lib/scintilla.a"
  install -Dm644 "${srcdir}/${_realname}/bin/lexilla.dll" "${pkgdir}${MINGW_PREFIX}/bin/lexilla.dll"
  install -Dm644 "${srcdir}/${_realname}/bin/libscintilla.dll" "${pkgdir}${MINGW_PREFIX}/bin/libscintilla.dll"
  
  # include
  install -Dm644 "${srcdir}/${_realname}/include/ILexer.h" "${pkgdir}${MINGW_PREFIX}/include/${_realname}/ILexer.h"
  install -Dm644 "${srcdir}/${_realname}/include/ILoader.h" "${pkgdir}${MINGW_PREFIX}/include/${_realname}/ILoader.h"
  install -Dm644 "${srcdir}/${_realname}/include/Platform.h" "${pkgdir}${MINGW_PREFIX}/include/${_realname}/Platform.h"
  install -Dm644 "${srcdir}/${_realname}/include/Sci_Position.h" "${pkgdir}${MINGW_PREFIX}/include/${_realname}/Sci_Position.h"
  install -Dm644 "${srcdir}/${_realname}/include/SciLexer.h" "${pkgdir}${MINGW_PREFIX}/include/${_realname}/SciLexer.h"
  install -Dm644 "${srcdir}/${_realname}/include/Scintilla.h" "${pkgdir}${MINGW_PREFIX}/include/${_realname}/Scintilla.h"
  install -Dm644 "${srcdir}/${_realname}/include/Scintilla.iface" "${pkgdir}${MINGW_PREFIX}/include/${_realname}/Scintilla.iface"
  install -Dm644 "${srcdir}/${_realname}/include/ScintillaWidget.h" "${pkgdir}${MINGW_PREFIX}/include/${_realname}/ScintillaWidget.h"
  
  # License
  install -Dm644 "${srcdir}/${_realname}/License.txt" "${pkgdir}${MINGW_PREFIX}/share/${_realname}/License.txt"
  install -Dm644 "${srcdir}/${_realname}/version.txt" "${pkgdir}${MINGW_PREFIX}/share/${_realname}/version.txt"
  install -Dm644 "${srcdir}/${_realname}/README" "${pkgdir}${MINGW_PREFIX}/share/${_realname}/README"
}
